using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using JGSY.CMS.LowCode.Platform.Application.DTOs;

namespace JGSY.CMS.LowCode.Platform.Application.Interfaces
{
    /// <summary>
    /// 导航应用服务接口
    /// 提供网站导航菜单管理的业务逻辑
    /// </summary>
    public interface INavigationAppService
    {
        /// <summary>
        /// 获取分页的导航列表
        /// </summary>
        /// <param name="query">查询参数</param>
        /// <returns>分页的导航列表</returns>
        Task<PagedResultDto<NavigationDto>> GetPagedListAsync(PagedQueryDto query);
        
        /// <summary>
        /// 获取树形导航列表
        /// </summary>
        /// <param name="parentId">父导航ID</param>
        /// <param name="includeDisabled">是否包含禁用的导航</param>
        /// <returns>树形导航列表</returns>
        Task<List<NavigationDto>> GetTreeAsync(long? parentId = null, bool includeDisabled = false);
        
        /// <summary>
        /// 获取前端导航菜单
        /// </summary>
        /// <param name="platform">平台类型 (desktop, mobile)</param>
        /// <returns>导航菜单</returns>
        Task<List<NavigationDto>> GetFrontendMenuAsync(string platform = "desktop");
        
        /// <summary>
        /// 根据ID获取导航详情
        /// </summary>
        /// <param name="id">导航ID</param>
        /// <returns>导航详情</returns>
        Task<NavigationDto?> GetByIdAsync(long id);
        
        /// <summary>
        /// 创建导航
        /// </summary>
        /// <param name="dto">导航数据</param>
        /// <returns>创建的导航</returns>
        Task<NavigationDto> CreateAsync(NavigationDto dto);
        
        /// <summary>
        /// 更新导航
        /// </summary>
        /// <param name="id">导航ID</param>
        /// <param name="dto">更新的导航数据</param>
        /// <returns>更新后的导航</returns>
        Task<NavigationDto> UpdateAsync(long id, NavigationDto dto);
        
        /// <summary>
        /// 删除导航
        /// </summary>
        /// <param name="id">导航ID</param>
        /// <param name="deleteChildren">是否删除子导航</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteAsync(long id, bool deleteChildren = false);
        
        /// <summary>
        /// 批量删除导航
        /// </summary>
        /// <param name="ids">导航ID列表</param>
        /// <param name="deleteChildren">是否删除子导航</param>
        /// <returns>删除结果</returns>
        Task<bool> BatchDeleteAsync(List<long> ids, bool deleteChildren = false);
        
        /// <summary>
        /// 移动导航
        /// </summary>
        /// <param name="id">导航ID</param>
        /// <param name="newParentId">新父导航ID</param>
        /// <returns>移动结果</returns>
        Task<bool> MoveAsync(long id, long? newParentId);
        
        /// <summary>
        /// 获取子导航
        /// </summary>
        /// <param name="parentId">父导航ID</param>
        /// <returns>子导航列表</returns>
        Task<List<NavigationDto>> GetChildrenAsync(long parentId);
        
        /// <summary>
        /// 批量更新排序权重
        /// </summary>
        /// <param name="sortData">排序数据</param>
        /// <returns>更新结果</returns>
        Task<bool> BatchUpdateSortAsync(Dictionary<long, int> sortData);
        
        /// <summary>
        /// 启用/禁用导航
        /// </summary>
        /// <param name="id">导航ID</param>
        /// <param name="enabled">是否启用</param>
        /// <returns>操作结果</returns>
        Task<bool> SetEnabledAsync(long id, bool enabled);
        
        /// <summary>
        /// 增加点击次数
        /// </summary>
        /// <param name="id">导航ID</param>
        /// <returns>更新结果</returns>
        Task<bool> IncrementClickCountAsync(long id);
        
        /// <summary>
        /// 检查导航权限
        /// </summary>
        /// <param name="id">导航ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns>是否有权限</returns>
        Task<bool> CheckPermissionAsync(long id, long userId);
        
        /// <summary>
        /// 根据用户权限过滤导航
        /// </summary>
        /// <param name="navigations">导航列表</param>
        /// <param name="userId">用户ID</param>
        /// <returns>过滤后的导航列表</returns>
        Task<List<NavigationDto>> FilterByPermissionAsync(List<NavigationDto> navigations, long userId);
        
        /// <summary>
        /// 获取面包屑导航
        /// </summary>
        /// <param name="id">导航ID</param>
        /// <returns>面包屑导航</returns>
        Task<List<NavigationDto>> GetBreadcrumbAsync(long id);
        
        /// <summary>
        /// 根据URL获取导航
        /// </summary>
        /// <param name="url">URL</param>
        /// <returns>导航信息</returns>
        Task<NavigationDto?> GetByUrlAsync(string url);
        
        /// <summary>
        /// 复制导航
        /// </summary>
        /// <param name="id">原导航ID</param>
        /// <param name="newTitle">新导航标题</param>
        /// <returns>复制的导航</returns>
        Task<NavigationDto> CopyAsync(long id, string newTitle);
        
        /// <summary>
        /// 导出导航数据
        /// </summary>
        /// <returns>导出数据</returns>
        Task<byte[]> ExportAsync();
        
        /// <summary>
        /// 导入导航数据
        /// </summary>
        /// <param name="data">导入数据</param>
        /// <returns>导入结果</returns>
        Task<List<NavigationDto>> ImportAsync(byte[] data);
        
        /// <summary>
        /// 检查导航标题是否存在
        /// </summary>
        /// <param name="title">导航标题</param>
        /// <param name="parentId">父导航ID</param>
        /// <param name="excludeId">排除的导航ID</param>
        /// <returns>是否存在</returns>
        Task<bool> ExistsAsync(string title, long? parentId = null, long? excludeId = null);
    }
}
